<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::connection('mysql_log')->create('log_wx_minigame_jumpgame', function (Blueprint $table) {
            $table->engine  = 'InnoDB';
            $table->comment('记录用户小程序跳转历史');

            $table->increments('id');
            $table->integer('create_time')->comment('创建时间')->unsigned()->default(0);
            $table->string('appid', 32)->comment('小游戏appid')->default('');
            $table->string('openid', 32)->comment('用户openid')->default('');
            $table->string('ip', 64)->comment('用户ip')->default('');
            $table->tinyInteger('jump_type')->comment('跳转方式 1不跳 2b面')->unsigned()->default(0);
            $table->integer('login_time')->comment('最后登录时间')->unsigned()->default(0);
            $table->integer('login_num')->comment('登录次数')->unsigned()->default(0);
            $table->string('launch_info', 600)->comment('携带路径参数')->default('');
            $table->tinyInteger('is_del')->comment('是否删除 1是')->unsigned()->default(0);
            $table->string('login_ip', 64)->comment('最后登录ip')->default('');
            $table->integer('scene')->comment('首次打开场景值')->unsigned()->default(0);
            $table->integer('login_scene')->comment('最近打开场景值')->unsigned()->default(0);
            $table->tinyInteger('first_jump')->comment('首次跳转方式')->unsigned()->default(0);
            $table->tinyInteger('login_jump')->comment('最近跳转方式')->unsigned()->default(0);

            $table->index('create_time');
            $table->index('appid');
            $table->index('openid');
            $table->index('login_time');
            $table->index('ip');
            $table->index('jump_type');
            $table->index('login_ip');
            $table->index('scene');
            $table->index('login_scene');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::connection('mysql_log')->dropIfExists('log_wx_minigame_jumpgame');
    }
};
